package com.ruoyi.system.domain.params;

import com.ruoyi.common.utils.StringUtils;
import lombok.Data;

/**
 * @author: 陈平安
 * @date: 2023/3/13 0:26
 * @description: 打印模板参数
 */
@Data
public class PrintParams {

    // 换行
    private static final String BR = "<BR>";
    private static final String DBR = "<BR><BR>";
    // 切刀指令
    private static final String CUT = "<CUT>";
    // 放大一倍
    private static final String L1 = "<L1>%s</L1>";
    // 放大两倍
    private static final String L2 = "<L2>%s</L2>";
    // 居中
    private static final String C = "<C>%s</C>";
    // 字体变高一倍
    private static final String H = "<H>%s</H>";
    // 字体变宽一倍
    private static final String W = "<W>%s</W>";
    // 右对齐
    private static final String R = "<R>%s</R>";
    // 字体加粗
    private static final String B = "<B>%s</B>";
    // 二维码
    private static final String QRCODE = "<QRCODE>%s</QRCODE>";

    /**
     * 标题
     */
    private String title;

    private String enTitle;

    /**
     * 订单模板名称
     */
    private String templateNameEn;
    private String templateNameCn;

    /**
     * 公司地址标题
     */
    private String companyAddressTile;
    private String companyAddress;

    /**
     * 订单号
     */
    private String orderNoTile;
    private String orderNo;

    /**
     * 入仓日期
     */
    private String dateTitle;
    private String date;

    /**
     * 客户代码
     */
    private String customerCodeTitle;
    private String customerCode;

    /**
     * 客户名称
     */
    private String customerNameTitle;
    private String customerName;

    /**
     * 客户电话
     */
//    private String customerPhoneTitle;
//    private String customerPhone;

    /**
     * 客户国籍
     */
    private String customerNationalityTitle;
    private String customerNationality;

    /**
     * 货物名称
     */
    private String goodsNameTitle;
    private String goodsName;

    /**
     * 包装数量
     */
    private String packageQuantityTitle;
    private String packageQuantity;

    /**
     * 货物数量
     */
    private String quantityTitle;
    private String quantity;

    /**
     * 存放区号
     */
    private String locationTitle;
    private String location;

    /**
     * 档口地址
     */
    private String stallAddressTitle;
    private String stallAddress;

    /**
     * 档口电话
     */
    private String stallPhoneTitle;
    private String stallPhone;

    /**
     * 打印日期
     */
    private String printDate;

    /**
     * 二维码
     */
    private String qrCode;

    /**
     * 底部信息
     */
    private String bottom;

    public String getTitle() {
        return String.format(C, String.format(L2,String.format(B,String.format(H,title))));
    }

    public String getEnTitle() {
        return String.format(C, String.format(L2,String.format(B,enTitle))) + DBR;
    }

    public String getTemplateNameEn() {
        this.templateNameEn = String.format(B, "BILL OF RECEIVED GOODS") + BR;
        return templateNameEn;
    }

    public String getTemplateNameCn() {
        this.templateNameCn = String.format(L1,String.format(B, "进仓单") + DBR);
        return templateNameCn;
    }

    public String getCompanyAddressTile() {
        this.companyAddressTile = "Address/地：" + BR;
        return companyAddressTile;
    }

    public String getCompanyAddress() {
        return companyAddress + DBR;
    }

    public String getOrderNoTile() {
        this.orderNoTile = "Receipt/单号：" + BR;
        return orderNoTile;
    }

    public String getOrderNo() {
        return String.format(L1,String.format(B, orderNo)) + DBR;
    }

    public String getDateTitle() {
        this.dateTitle = "Date/日期：" + BR;
        return dateTitle;
    }

    public String getDate() {
        return String.format(L1,String.format(B, date) + DBR);
    }

    public String getCustomerCodeTitle() {
        this.customerCodeTitle = "Customer Code/客户代号：" + BR;
        return customerCodeTitle;
    }

    public String getCustomerCode() {
        return String.format(L1,String.format(B, customerCode)) + DBR;
    }

    public String getCustomerNameTitle() {
        this.customerNameTitle = "Customer name/客户名字：" + BR;
        return customerNameTitle;
    }

    public String getCustomerName() {
        return String.format(L1,String.format(B, customerName)) + DBR;
    }

//    public String getCustomerPhoneTitle() {
//        this.customerPhoneTitle = "Customer Phone/客户电话：" + BR;
//        return customerPhoneTitle;
//    }

//    public String getCustomerPhone() {
//        return String.format(L1,String.format(B,StringUtils.isEmpty(customerPhone) ? "" : customerPhone)) + DBR;
//    }

    public String getCustomerNationalityTitle() {
        this.customerNationalityTitle = "Customer Nationality/客户国籍：" + BR;
        return customerNationalityTitle;
    }

    public String getCustomerNationality() {
        return String.format(L1,String.format(B,customerNationality)) + DBR;
    }

    public String getGoodsNameTitle() {
        this.goodsNameTitle = "Goods name/货名：" + BR;
        return goodsNameTitle;
    }

    public String getGoodsName() {
        return String.format(L1,String.format(B, goodsName)) + DBR;
    }

    public String getPackageQuantityTitle() {
        this.packageQuantityTitle = "Package Quantity/包装数量：" + BR;
        return packageQuantityTitle;
    }

    public String getPackageQuantity() {
        return String.format(L1,String.format(B, packageQuantity)) + DBR;
    }

    public String getQuantityTitle() {
        this.quantityTitle = "Quantity/数量：" + BR;
        return quantityTitle;
    }

    public String getQuantity() {
        return String.format(L1,String.format(B, quantity)) + DBR;
    }

    public String getLocationTitle() {
        this.locationTitle = "Location/区号：" + BR;
        return locationTitle;
    }

    public String getLocation() {
        return String.format(L1,String.format(B, location)) + DBR;
    }

    public String getStallAddressTitle() {
        this.stallAddressTitle = "Stall Address/档口地址：" + BR;
        return stallAddressTitle;
    }

    public String getStallAddress() {
        return String.format(L1,String.format(B, stallAddress)) + DBR;
    }

    public String getStallPhoneTitle() {
        this.stallPhoneTitle = "Stall Phone/档口电话：" + BR;
        return stallPhoneTitle;
    }

    public String getStallPhone() {
        return String.format(L1,String.format(B, stallPhone)) + DBR;
    }

    public String getPrintDate() {
        return String.format(L1,String.format(B, printDate)) + DBR;
    }

    public String getQrCode() {
        return String.format(QRCODE, qrCode) + DBR;
    }

    public String getBottom() {
        return String.format(C, bottom) + BR;
    }

    public String printContent(PrintParams params) {
        StringBuilder content = new StringBuilder("");
        content.append(params.getTitle());
        content.append(params.getEnTitle());
        content.append(params.getTemplateNameEn());
        content.append(params.getTemplateNameCn());
        content.append(params.getOrderNoTile());
        content.append(params.getOrderNo());
//        content.append(params.getDateTitle());
//        content.append(params.getDate());
//        content.append(params.getCustomerCodeTitle());
//        content.append(params.getCustomerCode());
        content.append(params.getCustomerNameTitle());
        content.append(params.getCustomerName());

//        content.append(params.getCustomerPhoneTitle());
//        content.append(params.getCustomerPhone());
//        content.append(params.getCustomerNationalityTitle());
//        content.append(params.getCustomerNationality());

        content.append(params.getGoodsNameTitle());
        content.append(params.getGoodsName());
        content.append(params.getPackageQuantityTitle());
        content.append(params.getPackageQuantity());
        content.append(params.getQuantityTitle());
        content.append(params.getQuantity());
        content.append(params.getLocationTitle());
        content.append(params.getLocation());
//        content.append(params.getStallAddressTitle());
//        content.append(params.getStallAddress());
        content.append(params.getStallPhoneTitle());
        content.append(params.getStallPhone());
        content.append(params.getCompanyAddressTile());
        content.append(params.getCompanyAddress());
        content.append(params.getPrintDate());
        content.append(params.getQrCode());
        content.append(params.getBottom());
        return content.toString();
    }
}
